<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<title>品优购，欢迎登录</title>
	<link rel="icon" href="/static/home/assets/img/favicon.ico">

	<link rel="stylesheet" type="text/css" href="/static/home/css/webbase.css" />
	<link rel="stylesheet" type="text/css" href="/static/home/css/pages-register.css" />
	<style>
	i{
		font-size: 12px;
		color: red;
	}
	</style>
</head>

<body>


	<div class="register py-container ">
		<!--head-->
		<div class="logoArea">
			<a href="" class="logo"></a>
		</div>
		<!--register-->
		<div class="registerArea">
			<h3>注册新用户<span class="go">我有账号，去<a href="/home/user/login" target="_blank">登陆</a></span></h3>
			<div class="info">
				<form class="sui-form form-horizontal" id="form1" action="/home/user/doregister" method="post">
					<div class="control-group">
						<label class="control-label">用户名：</label>
						<div class="controls">
							<input type="text" placeholder="请输入你的用户名" name="user_name" class="input-xfat input-xlarge">
						</div>
					</div>
					
					<div class="control-group">
						<label for="inputPassword" class="control-label">登录密码：</label>
						<div class="controls">
							<input type="password" id="password" name="password" placeholder="设置登录密码" class="input-xfat input-xlarge">
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">确认密码：</label>
						<div class="controls">
							<input type="password" name="repassword" placeholder="再次确认密码" class="input-xfat input-xlarge">
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">手机号：</label>
						<div class="controls">
							<input type="text" id="phone1" name="phone" placeholder="请输入你的手机号" class="input-xfat input-xlarge">
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">短信验证码：</label>
						<div class="controls">
							<input type="text" id="code1" name="code" placeholder="短信验证码" class="input-xfat input-xlarge"> 
							<a href="javascript:;" style="display: inline-block;font-size: 20px;line-height: 20px;">
								<input type="button" id="btnSendCode1" name="btnSendCode1" onclick="sendMessage1()"  value="获取短信验证码">
							</a>
						</div>
					</div>
					
					<div class="control-group">
						<label for="inputPassword" class="control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
						<div class="controls">
							<input type="checkbox" id="checkbox" name="ml"  value="2" checked><span>同意协议并注册《品优购用户协议》</span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls btn-reg">
							<input class="sui-btn btn-block btn-xlarge btn-danger" id="btn-form" type="button" value="完成注册">
						</div>
					</div>
				</form>
				<div class="clearfix"></div>
			</div>
		</div>
		<!--foot-->
		<div class="py-container copyright">
			<ul>
				<li>关于我们</li>
				<li>联系我们</li>
				<li>联系客服</li>
				<li>商家入驻</li>
				<li>营销中心</li>
				<li>手机品优购</li>
				<li>销售联盟</li>
				<li>品优购社区</li>
			</ul>
			<div class="address">地址：北京市昌平区建材城西路金燕龙办公楼一层 邮编：100096 电话：400-618-4000 传真：010-82935100</div>
			<div class="beian">京ICP备08001421号京公网安备110108007702
			</div>
		</div>
	</div>
	<script type="text/javascript" src="/static/home/js/plugins/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/static/home/js/plugins/jquery.easing/jquery.easing.min.js"></script>
	<script type="text/javascript" src="/static/home/js/plugins/sui/sui.min.js"></script>
	<script type="text/javascript" src="/static/home/js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
	<script type="text/javascript" src="/static/home/js/pages/login.js"></script>
	<script type="text/javascript" src="/static/home/js/validate/jquery.validate-1.17.0.min.js"></script>
	<script type="text/javascript" src="/static/home/js/validate/message_zh.js"></script>
	<script>
	
		document.getElementById('btn-form').setAttribute('type','submit');
		var c = document.getElementById('checkbox').val;
		console.log(c);

		$(function(){

			$("#form1").validate({
				//修改显示错误信息的标签
				// i 指的是：用<i></i>来显示错误信息
				"errorElement":"i",
				// debug:true 表示只验证表单输入是否正确，但是不提交表单
				// "debug":true,

				//验证规则
				"rules":{
					"user_name":{
						"required":true,
						"minlength":4,
						"maxlength":20
					},
					"password":{
						required:true,
						rangelength:[6,20]
					},
					"repassword":{
						required:true,
						equalTo:"#password"
					},
					"phone":{
						required:true,
					},
					"code":{
						digits:true,
					}
				}
			});

		})
	
	</script>
	<script>
		
		var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;//手机号正则 
			var count = 60; //间隔函数，1秒执行
			var InterValObj1; //timer变量，控制时间
			var curCount1;//当前剩余秒数
			/*第一*/
			function sendMessage1() {
				curCount1 = count;		 		 
				var phone = $.trim($('#phone1').val());
				if (!phoneReg.test(phone)) {
					alert(" 请输入有效的手机号码"); 
					return false;
				}
				//设置button效果，开始计时
				$("#btnSendCode1").attr("disabled", "true");
				$("#btnSendCode1").val( + curCount1 + "秒后重新获取");
				InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次
				//向后台发送处理数据
				$.post("/home/user/sendSms",{"phoneNum":phone,"r":Math.random()},function(data){
                // alert(data);
                if(data){
                    alert('验证码发送成功');
                }else{
					alert('验证码发送失败');
				}
			});   
			}
			function SetRemainTime1() {
				if (curCount1 == 0) {                
					window.clearInterval(InterValObj1);//停止计时器
					$("#btnSendCode1").removeAttr("disabled");//启用按钮
					$("#btnSendCode1").val("重新发送");
				}
				else {
					curCount1--;
					$("#btnSendCode1").val( + curCount1 + "秒后重新获取");
				}
			} 
			
			/*提交*/
			function binding(){
				alert(1)
			}
		
	
	</script>
	</body>
	
	</html>
